#!/usr/bin/env python2
import Combinations

matches = {}
def AddMatch(teams):
    global matches
    if len(teams) < 2:
        raise ValueError("Match has less than two teams")
    for teamPair in Combinations.GetAllCombinations(teams, 2):
        for i in [0, 1]:
            try:
                try:
                    matches[teamPair[i]][teamPair[1-i]] += 1
                except KeyError:
                    matches[teamPair[i]][teamPair[1-i]] = 1
            except KeyError:
                matches[teamPair[i]] = { teamPair[1-i] : 1 }

def GetMatchCount(team1, opposition):
    try:
        return matches[team1][opposition]
    except KeyError:
        return 0
